home *** CD-ROM | disk | FTP | other *** search
/ The Disc - MacWorld 1995 / PowerComputing (The Disc)(MacWorld 1995).ISO / mac / Jawai / JavaBea / JBeatMAC / Java Beat Demo / Java Beat Demo.dxr / 00112.ls < prev    next >
Encoding:
Text File  |  1995-07-13  |  5.8 KB  |  217 lines

  1. on startMovie
  2.   global soundLevelSprite, APbutton, fileList, listOfLabels, themeList
  3.   set fileList to [:]
  4.   set listOfLabels to [:]
  5.   set themeList to [:]
  6.   set soundLevelSprite to 48
  7.   set APbutton to 9
  8.   set the volume of sound 1 to 255
  9.   set the volume of sound 2 to 255
  10.   set the textHeight of field "readout" to 16
  11.   set the textHeight of field "readout reset" to 16
  12.   resetReadout()
  13.   setListOfFiles()
  14.   setLIstOfLabels()
  15.   setListOfThemes()
  16.   when keyDown then soundKeyControl 
  17.   if the optionDown then
  18.     go("main")
  19.   end if
  20. end
  21.  
  22. on stopMovie
  23.   resetReadout()
  24.   when keyDown then nothing
  25.   set the text of field "name of inactive choice" to " "
  26. end
  27.  
  28. on idle
  29.   if not soundBusy(1) then
  30.     if line 1 of field "readout" <> " " then
  31.       put " " into line 1 of field "readout"
  32.     end if
  33.     if line 2 of field "readout" <> " " then
  34.       put " " into line 2 of field "readout"
  35.     end if
  36.   end if
  37. end
  38.  
  39. on setListOfFiles
  40.   global fileList
  41.   set fileList to [:]
  42.   repeat with x = 1 to the number of lines in field "file name lookup list"
  43.     addProp(fileList, item 1 of line x of field "file name lookup list", x)
  44.   end repeat
  45. end
  46.  
  47. on setLIstOfLabels
  48.   global listOfLabels
  49.   set listOfLabels to [:]
  50.   set numOflabels to the number of lines in field "song labels"
  51.   repeat with x = 7 to 6 + numOflabels
  52.     addProp(listOfLabels, x, line x - 6 of field "song labels")
  53.   end repeat
  54. end
  55.  
  56. on setListOfThemes
  57.   global themeList
  58.   set themeList to [:]
  59.   repeat with x = 1 to the number of lines in field "filenames of the 12 themes"
  60.     addProp(themeList, x, item 1 of line x of field "filenames of the 12 themes")
  61.   end repeat
  62. end
  63.  
  64. on turnOffAllSprites
  65.   repeat with x = 1 to 48
  66.     set the puppet of sprite x to 0
  67.   end repeat
  68. end
  69.  
  70. on resetReadout whichTracks
  71.   set the text of field "readout" to the text of field "readout reset"
  72. end
  73.  
  74. on playArandomTheme
  75.   global themeList
  76.   set fileToPlay to getaProp(themeList, random(count(themeList)))
  77.   if the machineType = 256 then
  78.     set soundToPlay to fileToPlay & ".wav"
  79.     sound playFile 1, fileToPlay
  80.   else
  81.     sound playFile 1, fileToPlay
  82.   end if
  83. end
  84.  
  85. on copyAlert
  86.   alert("In the full version of Java Beat, this button will copy the selected " & "audio segment to your hard drive.")
  87. end
  88.  
  89. on goToAnInctiveChoice soundToPlay
  90.   global listOfLabels
  91.   sound stop 1
  92.   sound stop 2
  93.   set the text of field "name of inactive choice" to the name of cast the castNum of sprite the clickOn
  94.   set frameToGoTo to getaProp(listOfLabels, the clickOn)
  95.   if the labelList contains frameToGoTo then
  96.     go(frameToGoTo)
  97.   else
  98.     alert("handler goToAnInctiveChoice was unable to get the targeted label")
  99.   end if
  100.   if stringp(soundToPlay) then
  101.     if the machineType = 256 then
  102.       sound stop 1
  103.       set soundToPlay to soundToPlay & ".wav"
  104.       sound playFile 1, soundToPlay
  105.     else
  106.       sound stop 1
  107.       set soundToPlay to soundToPlay
  108.       sound playFile 1, soundToPlay
  109.     end if
  110.   end if
  111. end
  112.  
  113. on returnFromAnInctiveChoice
  114.   sound stop 1
  115.   go("main")
  116. end
  117.  
  118. on quitThisMovie
  119.   global soundLevelSprite
  120.   sound stop 1
  121.   sound stop 2
  122.   set the puppet of sprite soundLevelSprite to 0
  123.   put "soundlevel sprite = " & soundLevelSprite && the puppet of sprite soundLevelSprite
  124.   go("quitFrame")
  125. end
  126.  
  127. on playSoundFromclickList
  128.   global fileList
  129.   set clickedLine to the mouseLine
  130.   set fieldToUse to the name of cast the castNum of sprite the clickOn
  131.   set soundDescription to line clickedLine of field fieldToUse
  132.   sound stop 1
  133.   sound stop 2
  134.   hilite line clickedLine of field fieldToUse
  135.   set fileNumber to getaProp(fileList, soundDescription)
  136.   set fileName to item 2 of line fileNumber of field "file name lookup list"
  137.   set fileRate to item 3 of line fileNumber of field "file name lookup list"
  138.   set fileLength to item 4 of line fileNumber of field "file name lookup list"
  139.   if the machineType = 256 then
  140.     set fileName to fileName & ".WAV"
  141.   end if
  142.   set soundToPlay to fileName
  143.   sound playFile 1, soundToPlay
  144.   put fileName into line 1 of newReadout
  145.   put fileRate into line 2 of newReadout
  146.   put "   " & fileLength into word 2 of line 2 of newReadout
  147.   put newReadout into field "readOut"
  148. end
  149.  
  150. on soundKeyControl
  151.   if the key = 0 then
  152.     setSoundLevelMeter(0)
  153.   else
  154.     if (the key >= 1) and (the key <= 9) then
  155.       setSoundLevelMeter(the key)
  156.     end if
  157.   end if
  158.   dontPassEvent()
  159. end
  160.  
  161. on setSoundLevelMeter whichLevel
  162.   global userVolumeLevel, soundLevelSprite
  163.   if whichLevel < 0 then
  164.     set whichLevel to 0
  165.   else
  166.     if whichLevel > 9 then
  167.       set whichLevel to 9
  168.     end if
  169.   end if
  170.   set newSoundLevel to 28 * whichLevel
  171.   set the volume of sound 1 to newSoundLevel
  172.   set the volume of sound 2 to newSoundLevel
  173.   set userVolumeLevel to newSoundLevel
  174.   set soundlevelToShow to "sound level " & string(whichLevel)
  175.   set the castNum of sprite soundLevelSprite to the number of cast soundlevelToShow
  176.   updateStage()
  177. end
  178.  
  179. on threeDbutton whereToGoOrWhatToDo
  180.   set cOn to the clickOn
  181.   set mouseDownTime to the timer
  182.   set originalCastNum to the castNum of sprite cOn
  183.   set newCastNum to the castNum of sprite cOn + 1
  184.   set the puppet of sprite cOn to 1
  185.   set the castNum of sprite cOn to newCastNum
  186.   updateStage()
  187.   set rollOn to 1
  188.   repeat while the stillDown
  189.     if rollOver(cOn) and not rollOn then
  190.       set the castNum of sprite cOn to newCastNum
  191.       updateStage()
  192.       set rollOn to 1
  193.       next repeat
  194.     end if
  195.     if not rollOver(cOn) and rollOn then
  196.       set the castNum of sprite cOn to originalCastNum
  197.       updateStage()
  198.       set rollOn to 0
  199.     end if
  200.   end repeat
  201.   repeat while (mouseDownTime + 10) > the timer
  202.     nothing()
  203.   end repeat
  204.   if rollOn = 1 then
  205.     set the castNum of sprite cOn to originalCastNum
  206.     set the puppet of sprite cOn to 0
  207.     updateStage()
  208.   end if
  209.   if rollOn and stringp(whereToGoOrWhatToDo) then
  210.     if the labelList contains whereToGoOrWhatToDo then
  211.       go(whereToGoOrWhatToDo)
  212.     else
  213.       do(whereToGoOrWhatToDo)
  214.     end if
  215.   end if
  216. end
  217.